// Gère les fenêtres, la résolution. SDL et opengl en général.


#ifndef WINDOW_HANDLER_H 
#define WINDOW_HANDLER_H

#include <SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

int SCREEN_WIDTH = 640;
int SCREEN_HEIGHT = 480; // Quand saves.h sera près, il y aura des résolutions customisées
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;

int nwindow(){
  
  window = SDL_CreateWindow("Lighty", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
  SDL_GLContext context = SDL_GL_CreateContext(window);
    
  if(window==NULL){
        
    printf("Impossible de créer une fenêtre ! SDL_Error: %s\n",SDL_GetError());
        
  }
  
  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
  
  if(renderer==NULL){
  
    printf("Impossible de créer le rendu ! SDL_Error: %s\n",SDL_GetError());
   
  }
  
  SDL_GL_SwapWindow(window);
  return 0;

}

int resizewindow(int nwidth, int nheight){
  
  SDL_SetWindowSize(window, nwidth, nheight);
  SDL_RenderPresent(renderer);
  SDL_RenderClear(renderer);
  return 0;

}

int cwindow(){

  SDL_DestroyRenderer(renderer);
  SDL_DestroyWindow(window);
  window=NULL;
  
  return 0;

}

#endif
